package com.demo.pattern.corp.service.impl;

import com.demo.pattern.corp.entity.DemoEntity;
import com.demo.pattern.corp.pipeline.executor.PipelineExecutor;
import com.demo.pattern.corp.service.ModelService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Slf4j
@Service
public class ModelServiceImpl implements ModelService {

    @Resource
    private PipelineExecutor pipelineExecutor;
 
    /**
     * 提交模型（构建模型实例）
     */
    @Override
    public String buildModelInstance(DemoEntity demo) {
        boolean success = pipelineExecutor.handle(demo);

        // 创建模型实例成功
        if (success) {
            return "instanceId：" + demo.getInstanceId();
        }

        log.error("创建模式实例失败：{}", demo.getErrorMsg());
        return "创建模式实例失败：" + demo.getErrorMsg();
    }
}
 